// map reduce flat

Array.prototype.myMap = function (callback, thisArgs) {
    let newArr = []
    for (let i = 0; i < this.length; i++) {
        newArr[i] = callback.call(thisArgs, this[i], i, this);
    }
    return newArr;
}

Array.prototype.reduce = function (callback, initValue) {
    let acc = initValue ? initValue : this[0];
    for (let i = 0; i < this.length; i++) {
        acc = callback(acc, this[i], i, this);
    }
    return acc
}

Array.prototype.myFlat = function (deep = 1) {
    if(deep <= 0) return this;
    let newArr = [];
    let num = count;
    for(let i = 0; i< this.length; i++){
        if(Array.isArray(this[i])){
            newArr = newArr.concat(this[i].myFlat(--num)) 
        }else {
            newArr.push(this[i])
        }
    }
    return newArr
}